package cn.com.egova.erp.dao.impl;

import cn.com.egova.erp.dao.IDepDao;
import cn.com.egova.erp.entity.Dep;
import cn.com.egova.erp.utils.CommonUtil;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;


/**
 * Created by yuanchao on 2020/6/2.
 */
public class DepDao extends BaseDao<Dep> implements IDepDao {


    @Override
    public DetachedCriteria getDetachedCriteria(Dep t1, Dep t2, Object param) {
        DetachedCriteria criteria = DetachedCriteria.forClass(Dep.class);
        if (t1 != null && !CommonUtil.isEmpty(t1.getName())) {
            criteria.add(Restrictions.like("name", t1.getName(), MatchMode.ANYWHERE));
        }
        if (t1 != null && !CommonUtil.isEmpty(t1.getTele())) {
            criteria.add(Restrictions.like("tele", t1.getTele(), MatchMode.ANYWHERE));
        }
        return criteria;
    }
}
